'use strict';
import { Controller } from 'egg';

export default class FollowController extends Controller {
  public async addFollow() {
    const { ctx } = this;
    try {
      let res = await ctx.service.follow.addFollow(ctx.query);
      ctx.success(res, '操作成功');
    } catch (e) {
      console.log(e);
      ctx.error(423, ctx.helper.errorCode[423]);
    }
  }
  public async removeFollow() {
    const { ctx } = this;
    try {
      let res = await ctx.service.follow.removeFollow(ctx.query);
      ctx.success(res, '操作成功');
    } catch (e) {
      console.log(e);
      ctx.error(423, ctx.helper.errorCode[423]);
    }
  }

  public async isFollow() {
    const { ctx } = this;
    let res = await ctx.service.follow.isFollow(ctx.query);
    ctx.success(res);
  }

  public async getFollow() {
    const { ctx } = this;
    try {
      // console.log(ctx.query);
      // let cookie = this.ctx.cookies.get('name', {
      //   signed: true,
      //   encrypt: true
      // });
      // console.log(1);
      
      // console.log(cookie);
      
      let res = await ctx.service.follow.getFollow(ctx.query);
      ctx.success(res, '查询成功');
    } catch (e) {
      console.log(e);
      ctx.error(423, ctx.helper.errorCode[423]);
    }
  }
}